<html>
<head><meta charset="utf-8"><title>sysroot dependencies · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html">sysroot dependencies</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="168079328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168079328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168079328">(Jun 13 2019 at 19:50)</a>:</h4>
<p>So, I found the reason why we don't find the <code>impl&lt;T&gt; Deref for Arc&lt;T&gt;</code> -- we can't resolve <code>core::ops::Deref</code> from <code>alloc</code> because we don't have a dependency from <code>alloc</code> to <code>core</code>. We currently only have dependencies from <code>std</code> to other crates in the sysroot. I assume this is just an oversight? I'll try hard-coding the <code>alloc</code> -&gt; <code>core</code> dependency as well and see what happens.</p>



<a name="168084753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168084753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168084753">(Jun 13 2019 at 21:00)</a>:</h4>
<p>Yeah, that's an oversight. The question is, how we should infer the dependencies? I'd say just hard-coding them would be good enough: we did that in IntelliJ, and, while ocassionally this was annoying when the sysroot was restructured, in general its a low-maintainance thing</p>



<a name="168085042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168085042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168085042">(Jun 13 2019 at 21:04)</a>:</h4>
<p>how does rustc actually know the dependencies? does cargo pass them to it somehow?</p>



<a name="168085918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168085918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168085918">(Jun 13 2019 at 21:15)</a>:</h4>
<p>I think sysroot crates use <code>extern crate</code>. So, rustc sees <code>extern crate foo</code> and looks for <code>foo</code> in sysroot</p>



<a name="168085930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168085930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168085930">(Jun 13 2019 at 21:15)</a>:</h4>
<p>in other words, the deps are sort-of ambiently defined</p>



<a name="168085998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168085998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168085998">(Jun 13 2019 at 21:16)</a>:</h4>
<p>To faithully mimic it, we must add something like <code>sysroot: FxHashMap&lt;Name, Crate&gt;</code> to <code>CrateGraph</code>. But I think that sysroot concept is not really necessary, and I prefer to just expliceitelly list what depends on what</p>



<a name="168087521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168087521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168087521">(Jun 13 2019 at 21:41)</a>:</h4>
<p>oh, right... yeah, I agree then</p>



<a name="168087608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168087608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168087608">(Jun 13 2019 at 21:42)</a>:</h4>
<p>though it might be not too hard to write a tool which automatically outputs the dependencies in the sysroot <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="168087777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168087777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168087777">(Jun 13 2019 at 21:44)</a>:</h4>
<p>Yeah, I <em>think</em> one even can perhaps run <code>cargo metadata</code> in rustc and extract that info. Altenatively, one can copy-paste from <a href="https://github.com/intellij-rust/intellij-rust/blob/f5ffcd619472574e94c8a7babc05db8b9f2ea421/src/main/kotlin/org/rust/cargo/util/RustCrateUtil.kt#L37-L72" target="_blank" title="https://github.com/intellij-rust/intellij-rust/blob/f5ffcd619472574e94c8a7babc05db8b9f2ea421/src/main/kotlin/org/rust/cargo/util/RustCrateUtil.kt#L37-L72">https://github.com/intellij-rust/intellij-rust/blob/f5ffcd619472574e94c8a7babc05db8b9f2ea421/src/main/kotlin/org/rust/cargo/util/RustCrateUtil.kt#L37-L72</a> :D</p>



<a name="168097364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168097364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168097364">(Jun 14 2019 at 00:45)</a>:</h4>
<p>FWIW sysroot deps will hopefully soon be in dep-info <a href="https://github.com/rust-lang/rust/pull/61727" target="_blank" title="https://github.com/rust-lang/rust/pull/61727">https://github.com/rust-lang/rust/pull/61727</a></p>



<a name="168097409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168097409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168097409">(Jun 14 2019 at 00:46)</a>:</h4>
<p>w/o sysroot you don't really get to "just compile" crates that depend on alloc/std/core/proc_macro unless you explicitly always give crates access to them</p>



<a name="168097412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/sysroot%20dependencies/near/168097412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/sysroot.20dependencies.html#168097412">(Jun 14 2019 at 00:46)</a>:</h4>
<p>at least in the rustc model</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>